package Correct;

import java.awt.Color;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import Frame.FCTip;

public class Correct extends JFrame {
	private CorrectFunction correctFunction = new CorrectFunction();

	public Correct() {
		setTitle("修正工具");
		setIconImage(Toolkit.getDefaultToolkit().createImage("./image/GongZuoTai1.png"));
		setBounds(0, 0, 500, 380);
		setResizable(false);
		setLocationRelativeTo(null);
		setLayout(null);

		addWindowListener(new WindowListener() {
			@Override
			public void windowOpened(WindowEvent e) {
			}

			@Override
			public void windowIconified(WindowEvent e) {
			}

			@Override
			public void windowDeiconified(WindowEvent e) {
			}

			@Override
			public void windowDeactivated(WindowEvent e) {
			}

			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}

			@Override
			public void windowClosed(WindowEvent e) {
			}

			@Override
			public void windowActivated(WindowEvent e) {
			}
		});

		JLabel selectt = new JLabel("选择功能");
		selectt.setBounds(10, 10, 80, 20);
		this.add(selectt);
		JComboBox<String> select = new JComboBox<String>();
		select.addItem("test");
		select.addItem("修复地图实体数据");
		select.setBounds(80, 10, 400, 20);
		this.add(select);

		JScrollPane info = new JScrollPane();
		info.setBounds(10, 40, 470, 270);
		info.setBorder(BorderFactory.createLineBorder(Color.black));
		info.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		this.add(info);
		JTextArea infoo = new JTextArea();
		infoo.append("--------------------\nFC游戏编辑器数据修复工具 v1.0\n请先选择修复功能，然后点击开始。\n--------------------\n");
		infoo.setBounds(0, 0, info.getWidth(), info.getHeight());
		info.setViewportView(infoo);

		JButton ok = new JButton("开始");
		ok.setBounds(400, 320, 80, 20);
		this.add(ok);

		ok.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (correctFunction.startcorrect(infoo, select.getSelectedIndex()))
					new FCTip("数据修复", "修复完成!");
				else
					new FCTip("数据修复", "修复失败!");
			}
		});

		setVisible(true);
	}
}
